001 /* 002 * Copyright 2004 Stephen J. McConnell. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 013 * implied. 014 * 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package net.dpml.metro.info; 020 021 import net.dpml.lang.Enum; 022 023 /** 024 * Collection policy enummeration. 025 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a> 026 * @version 1.0.0 027 */ 028 public final class ThreadSafePolicy extends Enum 029 { 030 //------------------------------------------------------------------- 031 // static 032 //------------------------------------------------------------------- 033 034 /** 035 * Serial version identifier. 036 */ 037 static final long serialVersionUID = 1L; 038 039 /** 040 * Weak collection policy. 041 */ 042 public static final ThreadSafePolicy TRUE = new ThreadSafePolicy( "true" ); 043 044 /** 045 * Soft collection policy. 046 */ 047 public static final ThreadSafePolicy FALSE = new ThreadSafePolicy( "false" ); 048 049 /** 050 * Hard collection policy. 051 */ 052 public static final ThreadSafePolicy UNKNOWN = new ThreadSafePolicy( "unknown" ); 053 054 /** 055 * Array of static thread-safe policy enumeration values. 056 */ 057 private static final ThreadSafePolicy[] ENUM_VALUES = 058 new ThreadSafePolicy[]{TRUE, FALSE, UNKNOWN}; 059 060 /** 061 * Returns an array of policy enum values. 062 * @return the policies array 063 */ 064 public static ThreadSafePolicy[] values() 065 { 066 return ENUM_VALUES; 067 } 068 069 /** 070 * Internal constructor. 071 * @param label the enumeration label. 072 */ 073 private ThreadSafePolicy( String label ) 074 { 075 super( label ); 076 } 077 078 /** 079 * Parse the supplied name. 080 * @param value the value to parse 081 * @return the policy value 082 */ 083 public static ThreadSafePolicy parse( String value ) 084 { 085 if( value.equalsIgnoreCase( "true" ) ) 086 { 087 return TRUE; 088 } 089 else if( value.equalsIgnoreCase( "false" ) ) 090 { 091 return FALSE; 092 } 093 else if( value.equalsIgnoreCase( "unknown" ) ) 094 { 095 return UNKNOWN; 096 } 097 else 098 { 099 throw new IllegalArgumentException( value ); 100 } 101 } 102 }